package com.example.demofdfs.test.obj;

import java.io.Serializable;
import java.util.UUID;

@SuppressWarnings("serial")
public class Singleton implements Serializable {

	private static Singleton instance;
	
	private String id;
	
	private Singleton() {
		if (instance != null) {
			throw new RuntimeException("not null instance ");
		}
		this.id = UUID.randomUUID().toString();
	}
	
	public static Singleton instance() {
		if (instance == null) {
			synchronized (Singleton.class) {
				if (instance == null) {
					instance = new Singleton();
				}
			}
		}
		return instance;
	}
	
    private Object readResolve() {

        return instance();

    }

//	@Override
//	public String toString() {
//		return "SingleObj [id=" + id + "]";
//	}
	
	
	
}
